// 文档：https://echarts.apache.org/handbook/zh/basics/import#%E5%9C%A8-typescript-%E4%B8%AD%E6%8C%89%E9%9C%80%E5%BC%95%E5%85%A5
// 1. 引入echarts核心
import * as echarts from "echarts/core";
// 2. 引入需要使用的图表
import {
  BarChart,
  LineChart,
  PieChart,
  MapChart,
  EffectScatterChart,
  LinesChart,
} from "echarts/charts";
// 3. 引入需要使用的组件
import {
  TitleComponent,
  TooltipComponent,
  GridComponent,
  LegendComponent,
} from "echarts/components";

// import { LabelLayout, UniversalTransition } from 'echarts/features';
// 4. 渲染图表方式：canvas
import { CanvasRenderer } from "echarts/renderers";

import type {
  // 系列类型的定义后缀都为 SeriesOption
  BarSeriesOption,
  LineSeriesOption,
  PieSeriesOption,
  MapSeriesOption,
  EffectScatterSeriesOption,
  LinesSeriesOption,
} from "echarts/charts";
import type {
  // 组件类型的定义后缀都为 ComponentOption
  TitleComponentOption,
  TooltipComponentOption,
  GridComponentOption,
  LegendComponentOption,
} from "echarts/components";
import type { ComposeOption } from "echarts/core";

// 通过 ComposeOption 来组合出一个只有必须组件和图表的 Option 类型
export type ECOption = ComposeOption<
  | BarSeriesOption
  | TitleComponentOption
  | TooltipComponentOption
  | GridComponentOption
  | LineSeriesOption
  | LegendComponentOption
  | PieSeriesOption
  | MapSeriesOption
  | EffectScatterSeriesOption
  | LinesSeriesOption
>;

// 注册必须的组件
echarts.use([
  TitleComponent,
  TooltipComponent,
  GridComponent,
  BarChart,
  LineChart,
  CanvasRenderer,
  LegendComponent,
  PieChart,
  MapChart,
  EffectScatterChart,
  LinesChart,
]);

export default echarts;
